using System.Runtime.CompilerServices;
using SageKing.Designer.Core.Models;
using SageKing.Designer.Core.Activities.Flowchart.Attributes;
using SageKing.Designer.Core.Attributes;
using SageKing.Designer.Core.Models; 
using JetBrains.Annotations;
using SageKing.Designer.Core.Contracts;

namespace SageKing.Designer.Core.Activities.Flowchart.Activities;

/// <summary>
/// Performs a boolean condition and returns an outcome based on the the result.
/// </summary>
[FlowNode("True", "False")]
[Activity("SageKing", "Branching", "Evaluate a Boolean condition to determine which path to execute next.", DisplayName = "Decision")]
[PublicAPI]
public class FlowDecision : Activity
{
    /// <inheritdoc />
    public FlowDecision([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
    {
    }

    /// <inheritdoc />
    public FlowDecision(Func<ExpressionExecutionContext, bool> condition, [CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : this(source, line)
    {
        Condition = new(condition);
    }
    
    /// <inheritdoc />
    public FlowDecision(Func<ExpressionExecutionContext, ValueTask<bool>> condition, [CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : this(source, line)
    {
        Condition = new(condition);
    }
    
    /// <summary>
    /// The condition to evaluate.
    /// </summary>
    [Input(UIHint = InputUIHints.SingleLine)]
    public Input<bool> Condition { get; set; } = new(new Literal<bool>(false));
 
}